package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * BelongProject: firstProject
 * BelongPackage: com.atguigu.lease.common.exception
 * Description:
 *
 * @Author 段鑫涛
 * @Create 2025/4/25 16:23
 * @Version 1.0
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(LeaseException.class)
    public Result error(LeaseException e){
        System.out.println(e.getMessage() + e.getCause());
        return Result.fail(e.getCode(), e.getMessage());
    }
}
